home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / comms / other / dwarfx-tng / dwarfx / dwarfencode.amirx < prev    next >
Text File  |  1999-04-19  |  5KB  |  28 lines

  1. /* DWaRFEnCoDE V1.3 By David 'COolWAve' Newton
  2. \\ Can Encode messages into:
  3. //  Encrypted Cybeonix 1.3.3 messages
  4. \\  Encrypted MCF 4.8 messages (all 10 different tables)
  5. //  Encrypted SoundLeech 1.3 messages
  6. \\  Encrypted DWaRFx 2.2 messages using a key
  7. //
  8. \\  Usage: DwEncode [$MODE] [!KEY] [DESTINATION] message
  9. //
  10. \\   [$MODE] makes the encryptor use one of the following methods:
  11. //           $0-$9 = MCF (Using Encryption Table 0-9)
  12. \\           $A    = Cybeonix (Default)
  13. //           $B    = SoundLeech
  14. \\           $C    = DWaRFx (Uses [!KEY] to encrypt text, if [!KEY] isn't
  15. //                   Supplied, the channel name will be used instead)
  16. \\
  17. //   [!KEY] is used with the [$MODE] $C (any ascii text, except space)
  18. \\
  19. //   [DESTINATION] can output the message as one of the following:
  20. \\
  21. //    #[CHANNEL]  = sends the message to the channel (Default)
  22. \\    *TOPIC      = sets the current channels topic to the message
  23. //    /[NICK]     = sends a private message to [NICK] 
  24. \\
  25. //  Add to AmIRC with the following command (put this script in AMIRC:Rexx/)
  26. \\  /Alias X = /Rx DWaRFEnCoDE %p
  27. */
  28. Options Results;Parse Arg args;evnum=Substr(Address(),Pos('.',Address()));bold1=d2c(27);bold2=d2c(2);mode=10;key="";output="";Call SetClip('DFxTIME'evnum,Time());Do loop=1 To 3;type=Substr(args,1,1);Select;When type="$" Then;Do;Parse Value args With '$'mode args;If DataType(mode)~='NUM' Then;Do;mode=Upper(mode);Select;When mode='A' Then mode=10;When mode='B' Then mode=11;When mode='C' Then mode=12;Otherwise;End;End;If mode<0|mode>12 Then Call ERR(1);End;When type="!" Then;Do;Parse Value args With '!'key args;End;When type="#" Then Parse Value args With output args;When type="*" Then Parse Value args With output args;When type="/" Then Parse Value args With '/'output args;OtherWise;End;args=Strip(args,L);End;If args="" Then Call ERR(2);If mode<11 Then Call GET_TABLES;"GetChannel";channel=result;If output="" Then output=channel;If key="" Then;Do;If Left(output,1)='*' Then key=channel;Else key=output;End;umess=args;emess="";Select;When mode=11 Then;Do;/* Sound Leech encryption */;ln=Length(args);Do loop=1 To ln;ch=c2d(Substr(args,loop,1));If ch>32 Then ch=ch+128;emess=emess||d2c(ch);End;mess="[UTC234]: "d2c(03)||emess||d2c(03);End;When mode=12 Then;Do;/* DWaRFx Key encryption */;If key=channel|key=output Then echar='A4'x||'+';Else echar='A4'x||'-';km=1;kp.1=72;key=Upper(key);Do While key~="";ch=c2d(Substr(key,1,1));key=Delstr(key,1,1);If ch>112 Then ch=ch-150;If ch<32 Then ch=ch+70;kp.km=ch;km=km+1;End;args=Reverse('DFx 'args);kn=1;Do While args~="";etmp=c2d(Left(args,1))+kp.kn;args=Delstr(args,1,1);If etmp>255 Then etmp=etmp-256;emess=d2c(etmp)||emess;kn=kn+1;If kn>=km Then kn=1;End;mess=echar||emess;End;Otherwise;Do;/* MCF/Cybeonix Tables encryption */;If mode=10 Then args=Upper(args);Do Until args="";Parse Value args With wrd1 wrd2 args;emess=emess wrd1 Reverse(wrd2);End;mess=echar||Reverse(Translate(Strip(emess),table2,table1));End;End;If Upper(output)='*TOPIC' Then "Say /Topic "mess;Else "RAW PRIVMSG "output" :"mess;If Substr(output,1,1)~="#" Then "Echo P="bold1"x«DwEnCoDE» "bold2||output":"bold2 umess;Else "Echo P="bold1"x«DwEnCoDE» "umess;Exit;GET_TABLES:;/* Look for tables in clipboard first, then if not found, add manually */;If mode=10 Then;Do;echar='A9'x;table1=GetClip("ALINE.1");table2=GetClip("ELINE.10");If table1="" Then;Do;table1='? ZYXWVUTSRQPONMLKJIHGFEDCBA-0987654321}{][)($#@!,:.';Call SetClip("ALINE.1",table1);End;If table2="" Then;Do;table2=X2C(E7CFEEC2F3CEC1C7C0C3DBEACAFEDDF5E1E5FDFCE0FBD6CCE4F1EFF2);table2=table2||X2C(B6A4AFA5B0AEBFBAAAF7ACECDEA6C8A7D0E6DFF0B7B1F8B5);Call SetClip("ELINE.10",table2);End;End;Else;Do;echar='AE'x||mode;table1=GetClip("ALINE.2");table2=GetClip("ELINE."mode);If table1=""|table2="" Then;Do;Parse Source . . drawer .;tmp=Pos('/',drawer);If tmp=0 Then tmp=Pos(':',drawer);Else tmp=Lastpos('/',drawer);drawer=Left(drawer,tmp);If ~Open('file1',drawer||'MCF.Encrypt') Then;Do;'Echo P='d2c(1)'«DwEnCoDE» 'd2c(2)'MCF.Encrypt'd2c(2)' not found! (See Docs!)';'Echo P='d2c(1)'«DwEnCoDE» If you do not install this file, 'd2c(2)'|DWaRFx-TNG|'d2c(2)' won t be able to Encode/Decode MCF encrypted messages!';Exit;End;ln=Readln('file1');ln=Readln('file1');If table1="" Then;Do;table1=ln;SetClip("ALINE.2",table1);End;If table2="" Then;Do;Do loop=0 To 9;ln=Readln('file1');If loop=mode Then table2=ln;End;Call Setclip('ELINE.'mode,table2);End;End;End;Return;ERR:;Parse Arg errno;temp="P="bold1"x«DwEnCoDE» "bold2"Error: "bold2;Select;When errno=1 Then "Echo "temp"Mode not available!";When errno=2 Then "Echo "temp"No message to encrypt!";OtherWise;End;Exit;Return